package com.commonEncryptionAlgorithms.symmetry.AES;


import org.junit.Test;

import java.io.File;

public class Run {
    private static final String password = "wwy";
    private static final int passwordLen = 256;
    private static final AesUtil aesUtil = new AesUtil(AesEncryption.generateKey(password, passwordLen));

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            String encipherStr = aesUtil.encipher("hello");
            System.out.println(encipherStr);
            String decrypt = aesUtil.decrypt(encipherStr);
            System.out.println(decrypt);
            System.out.println("------");
        }

    }

    @Test
    public void test1() {
        String encipher = aesUtil.encipher("11111");
        System.out.println(encipher);
        String decrypt = aesUtil.decrypt(encipher);
        System.out.println(decrypt);
    }

    @Test
    public void test2() throws Exception {
        File sourceFile = new File("C:\\Users\\Administrator\\Desktop\\111.txt");
        File targetFile = new File("C:\\Users\\Administrator\\Desktop\\1112.txt");
        boolean encipher = aesUtil.encipher(sourceFile, targetFile);
        System.out.println(encipher);
    }

    @Test
    public void test3() throws Exception {
        File sourceFile = new File("C:\\Users\\Administrator\\Desktop\\1112.txt");
        File targetFile = new File("C:\\Users\\Administrator\\Desktop\\1113.txt");
        boolean encipher = aesUtil.decrypt(sourceFile, targetFile);
        System.out.println(encipher);
    }

    @Test
    public void encryptInfo() throws Exception {
        String password = "wwy";
        int passwordLen = 256;
        AesUtil aesUtil = new AesUtil(AesEncryption.generateKey(password, passwordLen));
        File sourceFile = new File("D:\\gitee_versionControllerProject\\other\\01公司相关\\02北京方正\\_04记录\\info.xlsx");
        File targetFile = new File("D:\\gitee_versionControllerProject\\other\\01公司相关\\02北京方正\\_04记录\\infoEncipher.txt");
        boolean encipher = aesUtil.encipher(sourceFile, targetFile);
        System.out.println(encipher);
    }

    @Test
    public void decryptInfo() throws Exception {
        String password = "wwy";
        int passwordLen = 256;
        AesUtil aesUtil = new AesUtil(AesEncryption.generateKey(password, passwordLen));
        File sourceFile = new File("D:\\infoEncipher.txt");
        File targetFile = new File("D:\\infoEncipher.xlsx");
        boolean encipher = aesUtil.decrypt(sourceFile, targetFile);
        System.out.println(encipher);
    }
}